export function timeDifference(timestamp) {
    const now = Date.now();
    const diff = now-timestamp;

    if (diff > 0) { // 过去的时间
        const diffMinutes = Math.floor(diff / 1000 / 60);
        const diffHours = Math.floor(diff / 1000 / 60 / 60);
        const diffDays = Math.floor(diff / 1000 / 60 / 60 / 24);
        const diffMonths = Math.floor(diff / 1000 / 60 / 60 / 24 / 30);

        if (diffMinutes < 1) {
            return '1分钟内';
        } else if (diffHours < 1) {
            return `${diffMinutes}分钟内`;
        } else if (diffDays < 1) {
            return `${diffHours}小时内`;
        } else if (diffMonths < 1) {
            return `${diffDays}天内`;
        } else if (diffMonths < 3) {
            return `${diffMonths}月内`;
        } else {
            return '3月以上';
        }
    } else { 
        return '未来的时间';
    }
}